package com.linjiahao.nettyOne.api;

import com.linjiahao.nettyOne.handler.HandlerServiceFactory;
import com.linjiahao.servicebase.common.NettyMessageType;
import com.linjiahao.servicebase.vo.NettyMessageVO;
import org.springframework.web.bind.annotation.*;

import java.net.UnknownHostException;

/**
 * @ClassName MessageAPI
 * @Description: 内部消息推送
 * @Author linjiahao
 * @Date 6/1/2022
 **/
@RestController
@RequestMapping("/api/inner")
public class MessageAPI {

    @PostMapping("/sendMessage")
    public void sendMessage(@RequestBody NettyMessageVO nettyMessageVO) throws UnknownHostException {
        HandlerServiceFactory.getHandlerService(NettyMessageType.getHandleNameByType(nettyMessageVO.getMessageType()))
                .handlerWebsocket(null,nettyMessageVO);
    }

}
